<?php
/**
 * Description:
 * Author: hezhizheng
 * Date: 2018/11/15
 * Time: 12:25
 * Created by Created by Panxsoft.
 */

namespace App\Services\Customers\Login;


use App\Exceptions\ApiErrCode;
use App\Exceptions\ApiException;
use App\Models\Customers\Customer;

class LoginFactory
{

    /**
     * @param string $type
     * @return NormaLoginService|SocialiteLoginService
     * @throws \Exception
     */
    public static function create(string $type)
    {
        switch ($type) {
            case Customer::LOGIN_TYPE_NORMAL;
                return new NormaLoginService;
                break;
            case Customer::LOGIN_TYPE_SOCIAL;
                return new SocialiteLoginService;
                break;
            default:
                throw new ApiException(ApiErrCode::CUSTOMIZE_ERROR, 'error login type');
        }
    }
}